package tomsung.cloud.agdc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tomsung.cloud.agdc.bean.Crop;
import tomsung.cloud.agdc.dao.CropMapper;

@Service("CropService")
public class CropService {

	@Autowired
	CropMapper cropMapper;
	
	public int createCrop(Crop record)
	{
		return cropMapper.insertSelective(record);
	}
	
	public int deleteCrop(Integer cropId, Integer cropType)
	{
		return cropMapper.deleteByPrimaryKey(cropId,cropType);
	}
	
	public Crop selectCrop(Integer cropId, Integer cropType)
	{
		return cropMapper.selectByPrimaryKey(cropId,cropType);
	}
	
	public List<Crop> selectCrops(Integer cropType)
	{
		return cropMapper.selectByType(cropType);
	}
	
	public int selectMaxCropID(Integer cropType)
	{
		return cropMapper.selectMaxCropID(cropType);
	}
	
	public int updateCrop(Crop record)
	{
		return cropMapper.updateByPrimaryKey(record);
	}
}
